package controller;

import dao.ShopDao;
import dao.firmDao;
import entity.Firm;
import entity.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/role")
public class firm {
    @Autowired
    private firmDao firmDao;
    @Autowired
    private ShopDao shopDao;
    @RequestMapping("showfirm")//显示所有的厂商
    @ResponseBody
    public List<Firm> showfirm(){//显示所有的厂商
        return firmDao.showFirm();
    }
    @RequestMapping("showShop")
    @ResponseBody
    public List<Shop> showShop(String firmId){//显示单个厂商的商品信息
      if(firmId.equals("kk")){
          List<Firm> list=firmDao.showFirm();
          int firmIds=list.get(0).getFirmId();
          return shopDao.showShop(firmIds);
      }else{
           return shopDao.showShop(Integer.parseInt(firmId));
      }
    }

}
